﻿using MiniFox.Configurations;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace MiniFox.Components
{
    /// <summary>
    /// 
    /// </summary>
    public class ComponentProviderCollection : KeyedCollection<string, ComponentProvider>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        protected override string GetKeyForItem(ComponentProvider item)
        {
            return item.Name;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="providerSettingsCollection"></param>
        public static implicit operator ComponentProviderCollection(ProviderSettingsCollection providerSettingsCollection)
        {
            var providers = new ComponentProviderCollection();
            foreach (ProviderSettings setting in providerSettingsCollection)
            {
                providers.Add(new ComponentProvider(setting.Name, setting.Type));
            }
            return providers;
        }
    }
}
